//
//  ActivityApplicationVC.swift
//  甜言蜜语
//
//  Created by yingli_yanfa_liuxingyu on 16/8/30.
//  Copyright © 2016年 wl. All rights reserved.
//

import UIKit
import SVProgressHUD
class ActivityApplicationVC: UIViewController {
    var id: String!
    var msg: regiestInfo?
    var nameStr: String!
    var addressStr: String!
    var postcodeStr: String!
    var telStr: String!
    
    @IBOutlet weak var textView: UITextView!
    @IBOutlet weak var name: UILabel!
    @IBOutlet weak var address: UILabel!
    @IBOutlet weak var postcode: UILabel!
    @IBOutlet weak var tel: UILabel!
    override func viewDidLoad() {
        super.viewDidLoad()
         publicMethod.setHUDStyle()
        self.textView.layer.masksToBounds = true
        self.textView.layer.borderWidth = 1
        self.name.text = nameStr
        self.address.text = addressStr
        self.postcode.text = postcodeStr
        self.tel.text = telStr
        
    }
    override func viewWillDisappear(animated: Bool) {
       
        super.viewWillDisappear(animated)
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    //MARK:target
    //修改地址
    @IBAction func modifyAddresss(sender: UIButton){
        let storyboard = UIStoryboard(name: "MySelf", bundle: nil)
        let vc = storyboard.instantiateViewControllerWithIdentifier("harvestAddressVC") as! harvestAddressVC
        vc.id = Int(self.id)!
        vc.type = "活动"
        self.navigationController?.pushViewController(vc, animated: true)
    }
    //提交申请
    @IBAction func complete(sender: UIButton){
        if self.textView.text == ""{
            SVProgressHUD.showErrorWithStatus("请填写申请理由")
           
            return
        }else{
            DataTool.completeReason(self.id, reason: self.textView.text, completionHandler: { (newModel) in
                guard newModel != nil else {
                return
                }
                self.msg = newModel
                SVProgressHUD.showSuccessWithStatus(self.msg?.msg)
               
                self.navigationController?.popToRootViewControllerAnimated(true)
                })

        }
        
    }
}
